<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="lushu">
	<title>备用金帐户充值</title>
	<script language="javascript" src="/script/common.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
	var creditUserId;
	function load(){
		Eui.showNavigation();
		setPages(["searchFormDiv","operationFormDiv"]);
	}
	function doDeposit(){
		if(!checkForm("depositForm"))return;
		var amount = $("depositForm").amount.value;
		DWR.call('tradeService.cashDeposit',creditUserId, Format.yuanToFen(amount),AccountType.CREDIT,0,function(v){
			showInformation("保证金帐户充值成功！充值金额"+amount+"元.")
			switchPage("searchFormDiv");
			$("depositForm").reset();
		});
	}
	function checkData(){
		var orgUniqueId = $("searchForm").orgUniqueId.value;
		var creditId = $("searchForm").creditId.value;
		if(orgUniqueId || creditId){
			DWR.call('creditTxService.findCreditUser', orgUniqueId, creditId,function(v){
				var def = v.cardUser;
				creditUserId = def.uniqueId;
				def.orgName = v.creditOrg.name;
				def.orgUniqueId =v.creditOrg.uniqueId;
				def.orgLevel = Common.getText("org_level",v.creditOrg.orgLevel);
				if (v.accounts){
					var acc = v.accounts["user_"+AccountType.CREDIT]
					def.balance = Format.fenToYuan(acc.balance);
					def.lowLimit = Format.fenToYuan(Math.abs(acc.lowLimit));
				}
				Common.showDetail("operationFormDiv",def);
			
				switchPage("operationFormDiv");
				$("searchForm").reset();
			});
		}else{
			showWarning("机构编号和保证金帐户编号不能同时为空！")
		}
	}	
	//选择机构方法
	function creditSelOrg(){
		SystemMgnt.selOrg(function(sorg) {
			$('searchForm').orgUniqueId.value = sorg.uniqueId;
		},{funcType : Constants.SELORG_ALL});
	}
	
	</script>
	</head>
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="searchFormDiv">
			<div class="form">
				<div class="formTitle">请输入要充值帐户的相关信息</div>	
				<form id='searchForm' action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" align="center">
						<tr>
							<td>
								<label>机构编号</label> <input type="text" size="22" name="orgUniqueId" value=""  maxlength="20"><a class="orga" href="#" onclick="creditSelOrg();">&nbsp;&nbsp;</a>
							</td>
							<td>
								<label>保证金账号</label> 
								<input type="text" size="22" name="creditId" value="" maxlength="20" >
							</td>
							<td><button type="button" onclick="checkData()">查  询</button></td>
						</tr>
					</table>
				</form>	
			</div>
		</div>
		
		<div id="operationFormDiv" style="display:none;" >
			<div class="form">
				<div class="formTitle">帐户明细</div>	
				<form id="operationForm" action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable" class="col2 label6">
						<tr class="label6">
							<td><label>机构名称</label> <span id="orgName" ></span></td>
							<td><label>机构编号</label> <span id="orgUniqueId" ></span></td>
						</tr>
						<tr class="label6">
							<td><label>等&nbsp;&nbsp;&nbsp;&nbsp;级</label> <span id="orgLevel" ></span></td>
							<td><label>帐号编号</label><span id="uniqueId"></span></td>
						</tr>
						<tr class="label6">
							<td><label>余&nbsp;&nbsp;&nbsp;&nbsp;额/元</label> <span id="balance" ></span></td>
							<td><label>透支额度/元</label><span id="lowLimit"></span></td>
						</tr>
					</table>
				</form>
			</div>
			
			<div class="form">
				<div class="formTitle">帐户充值</div>	
				<form id="depositForm" action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable" class="col2 label5">
						<tr>
							<td><label>充值金额/元</label> <input type="text" name="amount" onblur="checkV(this,'nonNegativeAmount',true)"><span class="des">*</span></td>
							<td>&nbsp;</td>
						</tr>
						
					</table>
				</form>
			</div>
			<p>
				<button type="button" onclick="doDeposit()">充 值</button>
				<button type="button" onclick="switchPage('searchFormDiv')">返 回</button>
			</p>
		</div>
			
	</body>
</html>